<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class House extends Model
{
    protected $table = 'house';
    protected $guarded = ['id'];
    protected $appends = ['province_name', 'city_name'];

    public function getProvinceNameAttribute()
    {
        $coll = Area::where(['id' => $this->attributes['province_id']])->first();
        if ($coll) {
            return $coll['title'];
        } else {
            return "--";
        }
    }

    public function getCityNameAttribute()
    {
        $coll = Area::where(['id' => $this->attributes['city_id']])->first();
        if ($coll) {
            return $coll['title'];
        } else {
            return "--";
        }
    }
}
